centos8升级openssh到9.0p1 您所在的位置:网站首页 openssh 最新版 centos8升级openssh到9.0p1

centos8升级openssh到9.0p1

2023-08-12 05:28| 来源: 网络整理| 查看: 265

由于openssh8.0有安全隐患,需要升级至8.1以上 一、环境介绍 查看openssh、openssl版本 [root@localhost ~]# openssl version

OpenSSL 1.1.1g 

[root@localhost ~]# ssh -V

OpenSSH_8.0p1, OpenSSL 1.1.1g

[root@localhost ~]# lsb_release -a

LSB Version: :core-4.1-amd64:core-4.1-noarch

Distributor ID: CentOS

Description: CentOS Linux release 8.2.2004 (Core)

Release: 8.2.2004

Codename: Core

二、安装配置telnet

为了防止ssh升级失败,没办法远程通过ssh登录服务器,所以安装telnet 2.1、安装telnet-server

[root@localhost ~]# yum -y install xinetd telnet-server

2.2、配置telnet

先看一下xinetd.d目录下是否有telnet文件 [root@localhost ~]# ll /etc/xinetd.d/telnet

ls: cannot access /etc/xinetd.d/telnet: No such file or directory 如果有,则将文件里面的disable = no改成disable = yes 如果没有,就进行下面的操作  

[root@localhost ~]# cat > /etc/xinetd.d/telnet /etc/securetty /etc/ssh/sshd_config [root@localhost ~]# echo 'PermitRootLogin yes' >> /etc/ssh/sshd_config [root@localhost ~]# echo 'PubkeyAuthentication yes' >> /etc/ssh/sshd_config [root@localhost ~]# echo 'PasswordAuthentication yes' >> /etc/ssh/sshd_config

如果是图形化界面,需要x11的话,需要配置如下

[root@localhost ~]# echo "X11Forwarding yes" >> /etc/ssh/sshd_config [root@localhost ~]# echo "X11UseLocalhost no" >> /etc/ssh/sshd_config                 [root@localhost ~]# echo "XAuthLocation /usr/bin/xauth" >> /etc/ssh/sshd_config

创建新的sshd二进制文件

[root@localhost ~]# mv /usr/sbin/sshd{,.bak} [root@localhost ~]# mv /usr/bin/ssh{,.bak} [root@localhost ~]# mv /usr/bin/ssh-keygen{,.bak} [root@localhost ~]# ln -s /usr/local/openssh/bin/ssh /usr/bin/ssh [root@localhost ~]# ln -s /usr/local/openssh/bin/ssh-keygen /usr/bin/ssh-keygen [root@localhost ~]# ln -s /usr/local/openssh/sbin/sshd /usr/sbin/sshd

可以查看安装的新版本ssh了

[root@localhost ~]# ssh -V OpenSSH_9.0p1, OpenSSL 1.1.1k FIPS 25 Mar 2021

4.5 创建开机启动服务

[root@localhost ~]# systemctl disable sshd --now [root@localhost ~]# mv /usr/lib/systemd/system/sshd.service{,.bak} [root@localhost ~]# systemctl daemon-reload [root@localhost ~]# cp -a ~/openssh-9.0p1/contrib/redhat/sshd.init /etc/init.d/sshd [root@localhost ~]# chkconfig --add sshd [root@localhost ~]# systemctl enable sshd --now

这个时候试一下远程ssh是否可以连接,能连接说明ssh安装成功,安全起见可以关闭telnet了

[root@localhost ~]# systemctl disable xinetd.service --now [root@localhost ~]# systemctl disable telnet.socket --now



【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有